replace

fun replace(@IdRes containerViewId: Int, @NonNull fragmentClass: Class<out Fragment>, @Nullable args: Bundle): FragmentTransaction(source)
open fun replace(@IdRes containerViewId: Int, @NonNull fragment: Fragment): FragmentTransaction(source)

Calls replace with a null tag.


fun replace(@IdRes containerViewId: Int, @NonNull fragmentClass: Class<out Fragment>, @Nullable args: Bundle, @Nullable tag: String): FragmentTransaction(source)

Replace an existing fragment that was added to a container. This is essentially the same as calling remove for all currently added fragments that were added with the same containerViewId and then add with the same arguments given here.

Return

Returns the same FragmentTransaction instance.

Parameters

containerViewId

Identifier of the container whose fragment(s) are to be replaced.

fragmentClass

The new fragment to place in the container, created via the FragmentManager's FragmentFactory.

args

Optional arguments to be set on the fragment.

tag

Optional tag name for the fragment, to later retrieve the fragment with FragmentManager.findFragmentByTag(String).


open fun replace(@IdRes containerViewId: Int, @NonNull fragment: Fragment, @Nullable tag: String): FragmentTransaction(source)

Replace an existing fragment that was added to a container. This is essentially the same as calling remove for all currently added fragments that were added with the same containerViewId and then add with the same arguments given here.

Return

Returns the same FragmentTransaction instance.

Parameters

containerViewId

Identifier of the container whose fragment(s) are to be replaced.

fragment

The new fragment to place in the container.

tag

Optional tag name for the fragment, to later retrieve the fragment with FragmentManager.findFragmentByTag(String).